<?php
/**
 * @filename:					HoldPlaceAction.class.php
 * @desc:						寄存位管理模块
 *
 * @author: 					张召
 * @copyright:					zhangzhao@huigeyuan.com
 * @date:						2011-05-05
 */
class HoldPlaceAction extends CommonAction
{
    function _initialize() {
    	parent::_initialize();
        $holdstate = D('hold_state');
        $statename = $holdstate->select();
        $this->assign('statename',$statename);

        $district =	new PlaceDistrictModel();        
		$districtname = $district->where("level=2")->select();//查询区
        $this->assign('districtname',$districtname);
		$this->id();
    }


    /**
    * 寄存区展示
    */
    function index()
    {
		$this->display ();
    }
	/**
    * 获取id
    */
    function id() {
        //传值id
        $id = $_REQUEST['id'];
        $district = new PlaceDistrictModel();
		$qu = $district->where("id=$id")->find();//查询所在区
		$this->assign('qu',$qu);
        $groupname = $district->where("pid=$id")->select();//查询排
        $this->assign('groupname',$groupname);

        $hold = new HoldPlaceModel();
        $list = $hold->select();
        $this->assign('list',$list);
        $this->assign('id',$id);
    }		
	/**
    * 寄存位查询
    */
    function common() {
        $this->display();
    }

    /**
    * 寄存位展示
    */
    function hold() {

        $this->display();
    }

    /**
    * 添加新的寄存位
    */
    public function add()
    {
		parent::add();
    }

    /**
    * 查看寄存位的详细信息
    */
    public function view()
    {
		parent::view();
    }

    /**
    * 修改或完善寄存位信息
    */
    public function edit()
    {
		parent::edit();
    }

    /**
    * 删除寄存位
    */
    public function delete()
    {
       parent::delete();
    }

    /**
    * 寄存位定价
    */
  	public function price()
  	{
		parent::edit();
  	}
    /**
    * 寄存位更改
    */	
	function update1() {
		$name=$this->getActionName();
		$model = D ( $name );
		$price = $_POST[price];
		$id = $_REQUEST [id];
		$b=explode(',',$id);
		$newid  =array();
        foreach($b as $v){
        	$newid[] =array($v) ;
        }
		if (false === $model->create ()) {
			$this->error ( $model->getError () );
		}
		// 更新数据
		foreach ($newid as $val){
		    $list=$model->where(array('id' => $val[0]))->setField('price',"$price");
		}
		if (false !== $list) {
			//成功提示
			$this->assign ( 'jumpUrl', Cookie::get ( '_currentUrl_' ) );
			$this->success ('定价成功!');
		} else {
			//错误提示
			$this->error ('定价失败!');
		}
	}
    /**
    * 添加排
    */	
	function addrow(){
		parent::add();	
	}
	function insert1() {
		$model = new PlaceDistrictModel();
		if (false === $model->create ()) {
			$this->error ( $model->getError () );
		}
		//保存当前数据对象
		$list=$model->add ();
		if ($list!==false) { //保存成功
			$this->assign ( 'jumpUrl', Cookie::get ( '_currentUrl_' ) );
			$this->success ('新增成功!');
		} else {
			//失败提示
			$this->assign ( 'jumpUrl', Cookie::get ( '_currentUrl_' ) );
			$this->error ('新增失败!');
		}
	}
	/**
    * 修改排
    */
	function editrow(){
		parent::edit();	
	}
	function updaterow() {
		$model = new PlaceDistrictModel();
		if (false === $model->create ()) {
			$this->error ( $model->getError () );
		}
		// 更新数据
		$list=$model->save ();
		if (false !== $list) {
			//成功提示
			$this->assign ( 'jumpUrl', Cookie::get ( '_currentUrl_' ) );
			$this->success ('编辑成功!');
		} else {
			//错误提示
			$this->error ('编辑失败!');
		}
	}
	
}

?>